﻿using EMC.VISITOR.ApplicationExtend;

namespace EMC.VISITOR.Tasks.Job
{
    /// <summary>
    /// 【施工人员状态每日变更】自动任务 50分钟执行一次
    /// </summary>
    [JobDetail("job_buildstatuschange", Description = "【施工人员状态每日变更】", GroupName = "hk", Concurrent = false)]
    [PeriodSeconds(3000, TriggerId = "trigger_job_buildstatuschange", Description = "【施工人员状态每日变更】", MaxNumberOfRuns = 0, RunOnStart = false)]
    public class BuildStatusChangeJob : BaseJob, IJob
    {
        public BuildStatusChangeJob(IServiceProvider serviceProvider) : base(serviceProvider)
        {

        }

        public override async Task<Tuple<SysLogAutoTask, string>> Run(SysLogAutoTask log, string paramter)
        {
            string message = string.Empty;
            log.Logtype = "HK";
            using var serviceScope = _serviceProvider.CreateScope();
            var service = serviceScope.ServiceProvider.GetService<VisitLogExtendService>();
            var count = await service.SetSGStatus();
            log.Request = paramter;
            log.Message = $"施工人员状态每日变更，执行数据：{count}条!";
            return new Tuple<SysLogAutoTask, string>(log, count.ToString());
        }
    }
}
